# coding=utf-8
# author=haishan09@gmail.com
import json
from django import forms
from django.db import models
from custom.widgets import JsonifyConfigWidget, FontawesomeSelect
from custom.configs import BaseConfig


class JsonifyConfigField(models.Field):

    description = 'custom jsonify config field'

    def __init__(self, *args, **kwargs):
        if kwargs.has_key('config'):
            self.config = kwargs.pop('config')
        else:
            self.config = BaseConfig()
        super(JsonifyConfigField, self).__init__(*args, **kwargs)

    def to_python(self, value):
        return json.loads(value)

    def formfield(self, **kwargs):
        defaults = {
            'form_class': forms.CharField,
            'widget': JsonifyConfigWidget(self.config)
        }
        defaults.update(kwargs)
        return super(JsonifyConfigField, self).formfield(**defaults)

    def get_internal_type(self):
        return 'TextField'

    def get_db_prep_save(self, value, *args, **kwargs):
        if isinstance(value, dict):
            value = json.dumps(value)
        return super(JsonifyConfigField, self).get_db_prep_save(value, *args, **kwargs)


class FontawesomeField(models.Field):

    description = 'custom fontawesome icon field'
    FontawesomeIcons = {
        "fa-camera": "&#xf030;", 
        "fa-building-o": "&#xf0f7;", 
        "fa-align-left": "&#xf036;", 
        "fa-hand-o-up": "&#xf0a6;", 
        "fa-external-link-square": "&#xf14c;", 
        "fa-get-pocket": "&#xf265;", 
        "fa-share-alt-square": "&#xf1e1;", 
        "fa-comment-o": "&#xf0e5;", 
        "fa-thumbs-o-down": "&#xf088;", 
        "fa-heart": "&#xf004;", 
        "fa-list": "&#xf03a;", 
        "fa-calendar-o": "&#xf133;", 
        "fa-search-minus": "&#xf010;", 
        "fa-life-buoy": "&#xf1cd;", 
        "fa-stethoscope": "&#xf0f1;", 
        "fa-bookmark": "&#xf02e;", 
        "fa-barcode": "&#xf02a;", 
        "fa-opencart": "&#xf23d;", 
        "fa-square": "&#xf0c8;", 
        "fa-bank": "&#xf19c;", 
        "fa-stack-overflow": "&#xf16c;", 
        "fa-check-square": "&#xf14a;", 
        "fa-bell-o": "&#xf0a2;", 
        "fa-unsorted": "&#xf0dc;", 
        "fa-leaf": "&#xf06c;", 
        "fa-skype": "&#xf17e;", 
        "fa-certificate": "&#xf0a3;", 
        "fa-car": "&#xf1b9;", 
        "fa-ship": "&#xf21a;", 
        "fa-navicon": "&#xf0c9;", 
        "fa-arrows-alt": "&#xf0b2;", 
        "fa-server": "&#xf233;", 
        "fa-cab": "&#xf1ba;", 
        "fa-cart-plus": "&#xf217;", 
        "fa-wifi": "&#xf1eb;", 
        "fa-meanpath": "&#xf20c;", 
        "fa-send-o": "&#xf1d9;", 
        "fa-subscript": "&#xf12c;", 
        "fa-shirtsinbulk": "&#xf214;", 
        "fa-sticky-note": "&#xf249;", 
        "fa-road": "&#xf018;", 
        "fa-digg": "&#xf1a6;", 
        "fa-cart-arrow-down": "&#xf218;", 
        "fa-tags": "&#xf02c;", 
        "fa-file-code-o": "&#xf1c9;", 
        "fa-buysellads": "&#xf20d;", 
        "fa-list-ul": "&#xf0ca;", 
        "fa-shopping-basket": "&#xf291;", 
        "fa-arrow-circle-o-down": "&#xf01a;", 
        "fa-file-movie-o": "&#xf1c8;", 
        "fa-slideshare": "&#xf1e7;", 
        "fa-toggle-left": "&#xf191;", 
        "fa-circle-o-notch": "&#xf1ce;", 
        "fa-hourglass": "&#xf254;", 
        "fa-mars-stroke-h": "&#xf22b;", 
        "fa-chevron-circle-up": "&#xf139;", 
        "fa-arrow-down": "&#xf063;", 
        "fa-y-combinator-square": "&#xf1d4;", 
        "fa-gbp": "&#xf154;", 
        "fa-umbrella": "&#xf0e9;", 
        "fa-sort-numeric-asc": "&#xf162;", 
        "fa-pencil-square": "&#xf14b;", 
        "fa-twitter": "&#xf099;", 
        "fa-lastfm": "&#xf202;", 
        "fa-bicycle": "&#xf206;", 
        "fa-user-times": "&#xf235;", 
        "fa-jsfiddle": "&#xf1cc;", 
        "fa-recycle": "&#xf1b8;", 
        "fa-bell-slash-o": "&#xf1f7;", 
        "fa-share-square-o": "&#xf045;", 
        "fa-yc-square": "&#xf1d4;", 
        "fa-save": "&#xf0c7;", 
        "fa-yen": "&#xf157;", 
        "fa-unlink": "&#xf127;", 
        "fa-ban": "&#xf05e;", 
        "fa-sort-amount-asc": "&#xf160;", 
        "fa-film": "&#xf008;", 
        "fa-caret-down": "&#xf0d7;", 
        "fa-file-text": "&#xf15c;", 
        "fa-file": "&#xf15b;", 
        "fa-cloud": "&#xf0c2;", 
        "fa-life-ring": "&#xf1cd;", 
        "fa-filter": "&#xf0b0;", 
        "fa-bluetooth-b": "&#xf294;", 
        "fa-caret-up": "&#xf0d8;", 
        "fa-sign-out": "&#xf08b;", 
        "fa-file-photo-o": "&#xf1c5;", 
        "fa-ticket": "&#xf145;", 
        "fa-skyatlas": "&#xf216;", 
        "fa-th-large": "&#xf009;", 
        "fa-hand-o-left": "&#xf0a5;", 
        "fa-dedent": "&#xf03b;", 
        "fa-html5": "&#xf13b;", 
        "fa-at": "&#xf1fa;", 
        "fa-dropbox": "&#xf16b;", 
        "fa-file-zip-o": "&#xf1c6;", 
        "fa-long-arrow-up": "&#xf176;", 
        "fa-times-circle-o": "&#xf05c;", 
        "fa-product-hunt": "&#xf288;", 
        "fa-chevron-circle-left": "&#xf137;", 
        "fa-tachometer": "&#xf0e4;", 
        "fa-cloud-download": "&#xf0ed;", 
        "fa-caret-square-o-down": "&#xf150;", 
        "fa-microphone-slash": "&#xf131;", 
        "fa-folder": "&#xf07b;", 
        "fa-trash-o": "&#xf014;", 
        "fa-file-archive-o": "&#xf1c6;", 
        "fa-bar-chart-o": "&#xf080;", 
        "fa-transgender-alt": "&#xf225;", 
        "fa-reddit-alien": "&#xf281;", 
        "fa-openid": "&#xf19b;", 
        "fa-sort-asc": "&#xf0de;", 
        "fa-pause-circle": "&#xf28b;", 
        "fa-archive": "&#xf187;", 
        "fa-eraser": "&#xf12d;", 
        "fa-clone": "&#xf24d;", 
        "fa-inbox": "&#xf01c;", 
        "fa-truck": "&#xf0d1;", 
        "fa-pied-piper-alt": "&#xf1a8;", 
        "fa-object-ungroup": "&#xf248;", 
        "fa-play-circle-o": "&#xf01d;", 
        "fa-eye": "&#xf06e;", 
        "fa-sun-o": "&#xf185;", 
        "fa-folder-o": "&#xf114;", 
        "fa-rebel": "&#xf1d0;", 
        "fa-bars": "&#xf0c9;", 
        "fa-cc-paypal": "&#xf1f4;", 
        "fa-simplybuilt": "&#xf215;", 
        "fa-won": "&#xf159;", 
        "fa-hand-lizard-o": "&#xf258;", 
        "fa-balance-scale": "&#xf24e;", 
        "fa-frown-o": "&#xf119;", 
        "fa-file-word-o": "&#xf1c2;", 
        "fa-arrow-circle-o-up": "&#xf01b;", 
        "fa-taxi": "&#xf1ba;", 
        "fa-map-o": "&#xf278;", 
        "fa-question": "&#xf128;", 
        "fa-meh-o": "&#xf11a;", 
        "fa-mail-reply": "&#xf112;", 
        "fa-caret-left": "&#xf0d9;", 
        "fa-stop": "&#xf04d;", 
        "fa-tv": "&#xf26c;", 
        "fa-spoon": "&#xf1b1;", 
        "fa-area-chart": "&#xf1fe;", 
        "fa-files-o": "&#xf0c5;", 
        "fa-gears": "&#xf085;", 
        "fa-pause": "&#xf04c;", 
        "fa-facebook": "&#xf09a;", 
        "fa-cutlery": "&#xf0f5;", 
        "fa-gratipay": "&#xf184;", 
        "fa-battery-empty": "&#xf244;", 
        "fa-hourglass-start": "&#xf251;", 
        "fa-pause-circle-o": "&#xf28c;", 
        "fa-arrow-circle-left": "&#xf0a8;", 
        "fa-shopping-cart": "&#xf07a;", 
        "fa-map-pin": "&#xf276;", 
        "fa-youtube-play": "&#xf16a;", 
        "fa-bed": "&#xf236;", 
        "fa-battery-quarter": "&#xf243;", 
        "fa-weixin": "&#xf1d7;", 
        "fa-exchange": "&#xf0ec;", 
        "fa-street-view": "&#xf21d;", 
        "fa-youtube": "&#xf167;", 
        "fa-angle-double-up": "&#xf102;", 
        "fa-forward": "&#xf04e;", 
        "fa-tumblr": "&#xf173;", 
        "fa-cog": "&#xf013;", 
        "fa-reddit-square": "&#xf1a2;", 
        "fa-arrow-circle-down": "&#xf0ab;", 
        "fa-battery-three-quarters": "&#xf241;", 
        "fa-venus-double": "&#xf226;", 
        "fa-tumblr-square": "&#xf174;", 
        "fa-angellist": "&#xf209;", 
        "fa-th": "&#xf00a;", 
        "fa-info": "&#xf129;", 
        "fa-eyedropper": "&#xf1fb;", 
        "fa-behance": "&#xf1b4;", 
        "fa-map-signs": "&#xf277;", 
        "fa-file-audio-o": "&#xf1c7;", 
        "fa-gavel": "&#xf0e3;", 
        "fa-glass": "&#xf000;", 
        "fa-hand-o-right": "&#xf0a4;", 
        "fa-cube": "&#xf1b2;", 
        "fa-mouse-pointer": "&#xf245;", 
        "fa-cc-stripe": "&#xf1f5;", 
        "fa-user-secret": "&#xf21b;", 
        "fa-lightbulb-o": "&#xf0eb;", 
        "fa-caret-square-o-up": "&#xf151;", 
        "fa-cc-amex": "&#xf1f3;", 
        "fa-sort-alpha-asc": "&#xf15d;", 
        "fa-caret-right": "&#xf0da;", 
        "fa-volume-down": "&#xf027;", 
        "fa-clock-o": "&#xf017;", 
        "fa-arrow-up": "&#xf062;", 
        "fa-folder-open-o": "&#xf115;", 
        "fa-shield": "&#xf132;", 
        "fa-dashcube": "&#xf210;", 
        "fa-rotate-right": "&#xf01e;", 
        "fa-angle-double-down": "&#xf103;", 
        "fa-xing": "&#xf168;", 
        "fa-hand-scissors-o": "&#xf257;", 
        "fa-scribd": "&#xf28a;", 
        "fa-sort": "&#xf0dc;", 
        "fa-facebook-official": "&#xf230;", 
        "fa-power-off": "&#xf011;", 
        "fa-linux": "&#xf17c;", 
        "fa-mars": "&#xf222;", 
        "fa-header": "&#xf1dc;", 
        "fa-user": "&#xf007;", 
        "fa-exclamation-circle": "&#xf06a;", 
        "fa-level-down": "&#xf149;", 
        "fa-vine": "&#xf1ca;", 
        "fa-tint": "&#xf043;", 
        "fa-wordpress": "&#xf19a;", 
        "fa-expeditedssl": "&#xf23e;", 
        "fa-slack": "&#xf198;", 
        "fa-cut": "&#xf0c4;", 
        "fa-user-md": "&#xf0f0;", 
        "fa-key": "&#xf084;", 
        "fa-star-half-empty": "&#xf123;", 
        "fa-tripadvisor": "&#xf262;", 
        "fa-opera": "&#xf26a;", 
        "fa-object-group": "&#xf247;", 
        "fa-heartbeat": "&#xf21e;", 
        "fa-laptop": "&#xf109;", 
        "fa-bomb": "&#xf1e2;", 
        "fa-angle-double-left": "&#xf100;", 
        "fa-quote-left": "&#xf10d;", 
        "fa-paw": "&#xf1b0;", 
        "fa-reddit": "&#xf1a1;", 
        "fa-cc-visa": "&#xf1f0;", 
        "fa-circle-o": "&#xf10c;", 
        "fa-odnoklassniki-square": "&#xf264;", 
        "fa-unlock": "&#xf09c;", 
        "fa-mail-reply-all": "&#xf122;", 
        "fa-hand-pointer-o": "&#xf25a;", 
        "fa-group": "&#xf0c0;", 
        "fa-microphone": "&#xf130;", 
        "fa-camera-retro": "&#xf083;", 
        "fa-maxcdn": "&#xf136;", 
        "fa-tty": "&#xf1e4;", 
        "fa-phone-square": "&#xf098;", 
        "fa-rmb": "&#xf157;", 
        "fa-toggle-down": "&#xf150;", 
        "fa-percent": "&#xf295;", 
        "fa-toggle-on": "&#xf205;", 
        "fa-fax": "&#xf1ac;", 
        "fa-code-fork": "&#xf126;", 
        "fa-y-combinator": "&#xf23b;", 
        "fa-map": "&#xf279;", 
        "fa-try": "&#xf195;", 
        "fa-diamond": "&#xf219;", 
        "fa-neuter": "&#xf22c;", 
        "fa-quote-right": "&#xf10e;", 
        "fa-mobile": "&#xf10b;", 
        "fa-bell-slash": "&#xf1f6;", 
        "fa-trademark": "&#xf25c;", 
        "fa-file-video-o": "&#xf1c8;", 
        "fa-mixcloud": "&#xf289;", 
        "fa-plus-circle": "&#xf055;", 
        "fa-btc": "&#xf15a;", 
        "fa-css3": "&#xf13c;", 
        "fa-fast-forward": "&#xf050;", 
        "fa-i-cursor": "&#xf246;", 
        "fa-credit-card": "&#xf09d;", 
        "fa-caret-square-o-left": "&#xf191;", 
        "fa-hourglass-3": "&#xf253;", 
        "fa-hourglass-2": "&#xf252;", 
        "fa-hourglass-1": "&#xf251;", 
        "fa-folder-open": "&#xf07c;", 
        "fa-trello": "&#xf181;", 
        "fa-train": "&#xf238;", 
        "fa-sheqel": "&#xf20b;", 
        "fa-repeat": "&#xf01e;", 
        "fa-file-powerpoint-o": "&#xf1c4;", 
        "fa-forumbee": "&#xf211;", 
        "fa-television": "&#xf26c;", 
        "fa-life-saver": "&#xf1cd;", 
        "fa-copy": "&#xf0c5;", 
        "fa-sticky-note-o": "&#xf24a;", 
        "fa-mars-double": "&#xf227;", 
        "fa-photo": "&#xf03e;", 
        "fa-black-tie": "&#xf27e;", 
        "fa-chevron-up": "&#xf077;", 
        "fa-chevron-down": "&#xf078;", 
        "fa-check-circle-o": "&#xf05d;", 
        "fa-plug": "&#xf1e6;", 
        "fa-deviantart": "&#xf1bd;", 
        "fa-dashboard": "&#xf0e4;", 
        "fa-hourglass-o": "&#xf250;", 
        "fa-plus": "&#xf067;", 
        "fa-cc-discover": "&#xf1f2;", 
        "fa-hashtag": "&#xf292;", 
        "fa-gamepad": "&#xf11b;", 
        "fa-rub": "&#xf158;", 
        "fa-times-circle": "&#xf057;", 
        "fa-history": "&#xf1da;", 
        "fa-sign-in": "&#xf090;", 
        "fa-sort-amount-desc": "&#xf161;", 
        "fa-bug": "&#xf188;", 
        "fa-transgender": "&#xf224;", 
        "fa-graduation-cap": "&#xf19d;", 
        "fa-whatsapp": "&#xf232;", 
        "fa-mercury": "&#xf223;", 
        "fa-medkit": "&#xf0fa;", 
        "fa-twitch": "&#xf1e8;", 
        "fa-arrow-left": "&#xf060;", 
        "fa-cny": "&#xf157;", 
        "fa-arrows": "&#xf047;", 
        "fa-map-marker": "&#xf041;", 
        "fa-facebook-f": "&#xf09a;", 
        "fa-plus-square": "&#xf0fe;", 
        "fa-male": "&#xf183;", 
        "fa-institution": "&#xf19c;", 
        "fa-check-circle": "&#xf058;", 
        "fa-xing-square": "&#xf169;", 
        "fa-intersex": "&#xf224;", 
        "fa-stumbleupon-circle": "&#xf1a3;", 
        "fa-pencil-square-o": "&#xf044;", 
        "fa-weibo": "&#xf18a;", 
        "fa-gear": "&#xf013;", 
        "fa-rocket": "&#xf135;", 
        "fa-bluetooth": "&#xf293;", 
        "fa-search-plus": "&#xf00e;", 
        "fa-stop-circle": "&#xf28d;", 
        "fa-bell": "&#xf0f3;", 
        "fa-lastfm-square": "&#xf203;", 
        "fa-fast-backward": "&#xf049;", 
        "fa-sliders": "&#xf1de;", 
        "fa-hotel": "&#xf236;", 
        "fa-steam": "&#xf1b6;", 
        "fa-reorder": "&#xf0c9;", 
        "fa-hand-paper-o": "&#xf256;", 
        "fa-circle-thin": "&#xf1db;", 
        "fa-share-square": "&#xf14d;", 
        "fa-qrcode": "&#xf029;", 
        "fa-terminal": "&#xf120;", 
        "fa-hospital-o": "&#xf0f8;", 
        "fa-random": "&#xf074;", 
        "fa-fort-awesome": "&#xf286;", 
        "fa-beer": "&#xf0fc;", 
        "fa-exclamation-triangle": "&#xf071;", 
        "fa-commenting": "&#xf27a;", 
        "fa-volume-up": "&#xf028;", 
        "fa-flag-checkered": "&#xf11e;", 
        "fa-ellipsis-h": "&#xf141;", 
        "fa-hand-spock-o": "&#xf259;", 
        "fa-crop": "&#xf125;", 
        "fa-paragraph": "&#xf1dd;", 
        "fa-google-plus-square": "&#xf0d4;", 
        "fa-ellipsis-v": "&#xf142;", 
        "fa-gift": "&#xf06b;", 
        "fa-strikethrough": "&#xf0cc;", 
        "fa-motorcycle": "&#xf21c;", 
        "fa-life-bouy": "&#xf1cd;", 
        "fa-reply-all": "&#xf122;", 
        "fa-paper-plane-o": "&#xf1d9;", 
        "fa-star-half": "&#xf089;", 
        "fa-download": "&#xf019;", 
        "fa-usb": "&#xf287;", 
        "fa-chevron-circle-down": "&#xf13a;", 
        "fa-calculator": "&#xf1ec;", 
        "fa-minus-square": "&#xf146;", 
        "fa-toggle-off": "&#xf204;", 
        "fa-contao": "&#xf26d;", 
        "fa-hand-o-down": "&#xf0a7;", 
        "fa-leanpub": "&#xf212;", 
        "fa-star-o": "&#xf006;", 
        "fa-pie-chart": "&#xf200;", 
        "fa-venus": "&#xf221;", 
        "fa-inr": "&#xf156;", 
        "fa-rupee": "&#xf156;", 
        "fa-eur": "&#xf153;", 
        "fa-lemon-o": "&#xf094;", 
        "fa-indent": "&#xf03c;", 
        "fa-mars-stroke-v": "&#xf22a;", 
        "fa-git": "&#xf1d3;", 
        "fa-envelope": "&#xf0e0;", 
        "fa-bitbucket-square": "&#xf172;", 
        "fa-legal": "&#xf0e3;", 
        "fa-gittip": "&#xf184;", 
        "fa-chevron-left": "&#xf053;", 
        "fa-cogs": "&#xf085;", 
        "fa-arrow-circle-o-left": "&#xf190;", 
        "fa-briefcase": "&#xf0b1;", 
        "fa-soccer-ball-o": "&#xf1e3;", 
        "fa-angle-left": "&#xf104;", 
        "fa-yc": "&#xf23b;", 
        "fa-coffee": "&#xf0f4;", 
        "fa-copyright": "&#xf1f9;", 
        "fa-toggle-up": "&#xf151;", 
        "fa-support": "&#xf1cd;", 
        "fa-cc-mastercard": "&#xf1f1;", 
        "fa-safari": "&#xf267;", 
        "fa-compress": "&#xf066;", 
        "fa-android": "&#xf17b;", 
        "fa-font": "&#xf031;", 
        "fa-arrow-right": "&#xf061;", 
        "fa-amazon": "&#xf270;", 
        "fa-bitbucket": "&#xf171;", 
        "fa-edge": "&#xf282;", 
        "fa-subway": "&#xf239;", 
        "fa-headphones": "&#xf025;", 
        "fa-hand-grab-o": "&#xf255;", 
        "fa-industry": "&#xf275;", 
        "fa-ge": "&#xf1d1;", 
        "fa-gg": "&#xf260;", 
        "fa-moon-o": "&#xf186;", 
        "fa-file-excel-o": "&#xf1c3;", 
        "fa-line-chart": "&#xf201;", 
        "fa-fighter-jet": "&#xf0fb;", 
        "fa-sort-alpha-desc": "&#xf15e;", 
        "fa-spotify": "&#xf1bc;", 
        "fa-minus": "&#xf068;", 
        "fa-share": "&#xf064;", 
        "fa-comment": "&#xf075;", 
        "fa-mars-stroke": "&#xf229;", 
        "fa-stack-exchange": "&#xf18d;", 
        "fa-pied-piper": "&#xf1a7;", 
        "fa-building": "&#xf1ad;", 
        "fa-thumbs-up": "&#xf164;", 
        "fa-chevron-circle-right": "&#xf138;", 
        "fa-adjust": "&#xf042;", 
        "fa-sellsy": "&#xf213;", 
        "fa-paypal": "&#xf1ed;", 
        "fa-hourglass-half": "&#xf252;", 
        "fa-sort-up": "&#xf0de;", 
        "fa-shekel": "&#xf20b;", 
        "fa-codiepie": "&#xf284;", 
        "fa-tablet": "&#xf10a;", 
        "fa-users": "&#xf0c0;", 
        "fa-angle-down": "&#xf107;", 
        "fa-eye-slash": "&#xf070;", 
        "fa-backward": "&#xf04a;", 
        "fa-hand-stop-o": "&#xf256;", 
        "fa-mail-forward": "&#xf064;", 
        "fa-link": "&#xf0c1;", 
        "fa-table": "&#xf0ce;", 
        "fa-tag": "&#xf02b;", 
        "fa-turkish-lira": "&#xf195;", 
        "fa-puzzle-piece": "&#xf12e;", 
        "fa-optin-monster": "&#xf23c;", 
        "fa-database": "&#xf1c0;", 
        "fa-instagram": "&#xf16d;", 
        "fa-volume-off": "&#xf026;", 
        "fa-unlock-alt": "&#xf13e;", 
        "fa-minus-circle": "&#xf056;", 
        "fa-hacker-news": "&#xf1d4;", 
        "fa-paperclip": "&#xf0c6;", 
        "fa-print": "&#xf02f;", 
        "fa-list-ol": "&#xf0cb;", 
        "fa-magnet": "&#xf076;", 
        "fa-calendar-minus-o": "&#xf272;", 
        "fa-linkedin": "&#xf0e1;", 
        "fa-paper-plane": "&#xf1d8;", 
        "fa-pinterest-square": "&#xf0d3;", 
        "fa-reply": "&#xf112;", 
        "fa-smile-o": "&#xf118;", 
        "fa-signal": "&#xf012;", 
        "fa-behance-square": "&#xf1b5;", 
        "fa-file-sound-o": "&#xf1c7;", 
        "fa-expand": "&#xf065;", 
        "fa-empire": "&#xf1d1;", 
        "fa-flash": "&#xf0e7;", 
        "fa-qq": "&#xf1d6;", 
        "fa-long-arrow-down": "&#xf175;", 
        "fa-odnoklassniki": "&#xf263;", 
        "fa-angle-double-right": "&#xf101;", 
        "fa-home": "&#xf015;", 
        "fa-bolt": "&#xf0e7;", 
        "fa-italic": "&#xf033;", 
        "fa-rss-square": "&#xf143;", 
        "fa-comments": "&#xf086;", 
        "fa-pinterest": "&#xf0d2;", 
        "fa-toggle-right": "&#xf152;", 
        "fa-list-alt": "&#xf022;", 
        "fa-bold": "&#xf032;", 
        "fa-internet-explorer": "&#xf26b;", 
        "fa-video-camera": "&#xf03d;", 
        "fa-sort-down": "&#xf0dd;", 
        "fa-anchor": "&#xf13d;", 
        "fa-medium": "&#xf23a;", 
        "fa-calendar": "&#xf073;", 
        "fa-superscript": "&#xf12b;", 
        "fa-wechat": "&#xf1d7;", 
        "fa-file-text-o": "&#xf0f6;", 
        "fa-th-list": "&#xf00b;", 
        "fa-user-plus": "&#xf234;", 
        "fa-times": "&#xf00d;", 
        "fa-gg-circle": "&#xf261;", 
        "fa-trash": "&#xf1f8;", 
        "fa-paste": "&#xf0ea;", 
        "fa-ambulance": "&#xf0f9;", 
        "fa-suitcase": "&#xf0f2;", 
        "fa-binoculars": "&#xf1e5;", 
        "fa-battery-full": "&#xf240;", 
        "fa-long-arrow-left": "&#xf177;", 
        "fa-picture-o": "&#xf03e;", 
        "fa-cc": "&#xf20a;", 
        "fa-calendar-times-o": "&#xf273;", 
        "fa-phone": "&#xf095;", 
        "fa-github-square": "&#xf092;", 
        "fa-hand-peace-o": "&#xf25b;", 
        "fa-windows": "&#xf17a;", 
        "fa-500px": "&#xf26e;", 
        "fa-calendar-check-o": "&#xf274;", 
        "fa-shopping-bag": "&#xf290;", 
        "fa-magic": "&#xf0d0;", 
        "fa-long-arrow-right": "&#xf178;", 
        "fa-connectdevelop": "&#xf20e;", 
        "fa-text-height": "&#xf034;", 
        "fa-houzz": "&#xf27c;", 
        "fa-align-right": "&#xf038;", 
        "fa-tasks": "&#xf0ae;", 
        "fa-hand-rock-o": "&#xf255;", 
        "fa-heart-o": "&#xf08a;", 
        "fa-underline": "&#xf0cd;", 
        "fa-file-image-o": "&#xf1c5;", 
        "fa-wheelchair": "&#xf193;", 
        "fa-bus": "&#xf207;", 
        "fa-play-circle": "&#xf144;", 
        "fa-plus-square-o": "&#xf196;", 
        "fa-rss": "&#xf09e;", 
        "fa-battery-0": "&#xf244;", 
        "fa-battery-1": "&#xf243;", 
        "fa-battery-2": "&#xf242;", 
        "fa-battery-3": "&#xf241;", 
        "fa-battery-4": "&#xf240;", 
        "fa-caret-square-o-right": "&#xf152;", 
        "fa-child": "&#xf1ae;", 
        "fa-space-shuttle": "&#xf197;", 
        "fa-pinterest-p": "&#xf231;", 
        "fa-outdent": "&#xf03b;", 
        "fa-lock": "&#xf023;", 
        "fa-dot-circle-o": "&#xf192;", 
        "fa-git-square": "&#xf1d2;", 
        "fa-clipboard": "&#xf0ea;", 
        "fa-renren": "&#xf18b;", 
        "fa-university": "&#xf19c;", 
        "fa-github": "&#xf09b;", 
        "fa-jpy": "&#xf157;", 
        "fa-vk": "&#xf189;", 
        "fa-adn": "&#xf170;", 
        "fa-code": "&#xf121;", 
        "fa-book": "&#xf02d;", 
        "fa-commenting-o": "&#xf27b;", 
        "fa-envelope-o": "&#xf003;", 
        "fa-columns": "&#xf0db;", 
        "fa-plane": "&#xf072;", 
        "fa-angle-right": "&#xf105;", 
        "fa-steam-square": "&#xf1b7;", 
        "fa-ioxhost": "&#xf208;", 
        "fa-play": "&#xf04b;", 
        "fa-flag-o": "&#xf11d;", 
        "fa-battery-half": "&#xf242;", 
        "fa-search": "&#xf002;", 
        "fa-mortar-board": "&#xf19d;", 
        "fa-step-backward": "&#xf048;", 
        "fa-money": "&#xf0d6;", 
        "fa-hourglass-end": "&#xf253;", 
        "fa-sort-numeric-desc": "&#xf163;", 
        "fa-step-forward": "&#xf051;", 
        "fa-pencil": "&#xf040;", 
        "fa-mobile-phone": "&#xf10b;", 
        "fa-question-circle": "&#xf059;", 
        "fa-close": "&#xf00d;", 
        "fa-crosshairs": "&#xf05b;", 
        "fa-apple": "&#xf179;", 
        "fa-wrench": "&#xf0ad;", 
        "fa-sitemap": "&#xf0e8;", 
        "fa-language": "&#xf1ab;", 
        "fa-automobile": "&#xf1b9;", 
        "fa-bar-chart": "&#xf080;", 
        "fa-file-o": "&#xf016;", 
        "fa-krw": "&#xf159;", 
        "fa-soundcloud": "&#xf1be;", 
        "fa-floppy-o": "&#xf0c7;", 
        "fa-upload": "&#xf093;", 
        "fa-arrow-circle-o-right": "&#xf18e;", 
        "fa-info-circle": "&#xf05a;", 
        "fa-cloud-upload": "&#xf0ee;", 
        "fa-twitter-square": "&#xf081;", 
        "fa-euro": "&#xf153;", 
        "fa-tree": "&#xf1bb;", 
        "fa-music": "&#xf001;", 
        "fa-stumbleupon": "&#xf1a4;", 
        "fa-genderless": "&#xf22d;", 
        "fa-file-picture-o": "&#xf1c5;", 
        "fa-scissors": "&#xf0c4;", 
        "fa-dollar": "&#xf155;", 
        "fa-google-wallet": "&#xf1ee;", 
        "fa-pagelines": "&#xf18c;", 
        "fa-feed": "&#xf09e;", 
        "fa-vimeo": "&#xf27d;", 
        "fa-futbol-o": "&#xf1e3;", 
        "fa-hdd-o": "&#xf0a0;", 
        "fa-remove": "&#xf00d;", 
        "fa-bullseye": "&#xf140;", 
        "fa-location-arrow": "&#xf124;", 
        "fa-female": "&#xf182;", 
        "fa-thumb-tack": "&#xf08d;", 
        "fa-align-justify": "&#xf039;", 
        "fa-external-link": "&#xf08e;", 
        "fa-arrow-circle-right": "&#xf0a9;", 
        "fa-level-up": "&#xf148;", 
        "fa-ils": "&#xf20b;", 
        "fa-foursquare": "&#xf180;", 
        "fa-venus-mars": "&#xf228;", 
        "fa-yelp": "&#xf1e9;", 
        "fa-exclamation": "&#xf12a;", 
        "fa-star": "&#xf005;", 
        "fa-google-plus": "&#xf0d5;", 
        "fa-ra": "&#xf1d0;", 
        "fa-h-square": "&#xf0fd;", 
        "fa-undo": "&#xf0e2;", 
        "fa-registered": "&#xf25d;", 
        "fa-edit": "&#xf044;", 
        "fa-cc-jcb": "&#xf24b;", 
        "fa-sort-desc": "&#xf0dd;", 
        "fa-tencent-weibo": "&#xf1d5;", 
        "fa-thumbs-down": "&#xf165;", 
        "fa-eject": "&#xf052;", 
        "fa-star-half-o": "&#xf123;", 
        "fa-linkedin-square": "&#xf08c;", 
        "fa-cubes": "&#xf1b3;", 
        "fa-fonticons": "&#xf280;", 
        "fa-yahoo": "&#xf19e;", 
        "fa-send": "&#xf1d8;", 
        "fa-check": "&#xf00c;", 
        "fa-compass": "&#xf14e;", 
        "fa-viacoin": "&#xf237;", 
        "fa-angle-up": "&#xf106;", 
        "fa-wikipedia-w": "&#xf266;", 
        "fa-asterisk": "&#xf069;", 
        "fa-paint-brush": "&#xf1fc;", 
        "fa-bookmark-o": "&#xf097;", 
        "fa-usd": "&#xf155;", 
        "fa-chevron-right": "&#xf054;", 
        "fa-ruble": "&#xf158;", 
        "fa-delicious": "&#xf1a5;", 
        "fa-drupal": "&#xf1a9;", 
        "fa-arrow-circle-up": "&#xf0aa;", 
        "fa-comments-o": "&#xf0e6;", 
        "fa-chrome": "&#xf268;", 
        "fa-check-square-o": "&#xf046;", 
        "fa-birthday-cake": "&#xf1fd;", 
        "fa-calendar-plus-o": "&#xf271;", 
        "fa-codepen": "&#xf1cb;", 
        "fa-stop-circle-o": "&#xf28e;", 
        "fa-chain-broken": "&#xf127;", 
        "fa-envelope-square": "&#xf199;", 
        "fa-creative-commons": "&#xf25e;", 
        "fa-spinner": "&#xf110;", 
        "fa-newspaper-o": "&#xf1ea;", 
        "fa-globe": "&#xf0ac;", 
        "fa-firefox": "&#xf269;", 
        "fa-vimeo-square": "&#xf194;", 
        "fa-star-half-full": "&#xf123;", 
        "fa-keyboard-o": "&#xf11c;", 
        "fa-align-center": "&#xf037;", 
        "fa-warning": "&#xf071;", 
        "fa-desktop": "&#xf108;", 
        "fa-cc-diners-club": "&#xf24c;", 
        "fa-thumbs-o-up": "&#xf087;", 
        "fa-dribbble": "&#xf17d;", 
        "fa-square-o": "&#xf096;", 
        "fa-fire": "&#xf06d;", 
        "fa-flickr": "&#xf16e;", 
        "fa-retweet": "&#xf079;", 
        "fa-minus-square-o": "&#xf147;", 
        "fa-google": "&#xf1a0;", 
        "fa-share-alt": "&#xf1e0;", 
        "fa-bitcoin": "&#xf15a;", 
        "fa-text-width": "&#xf035;", 
        "fa-arrows-v": "&#xf07d;", 
        "fa-image": "&#xf03e;", 
        "fa-joomla": "&#xf1aa;", 
        "fa-bullhorn": "&#xf0a1;", 
        "fa-fire-extinguisher": "&#xf134;", 
        "fa-arrows-h": "&#xf07e;", 
        "fa-refresh": "&#xf021;", 
        "fa-circle": "&#xf111;", 
        "fa-github-alt": "&#xf113;", 
        "fa-chain": "&#xf0c1;", 
        "fa-modx": "&#xf285;", 
        "fa-facebook-square": "&#xf082;", 
        "fa-flask": "&#xf0c3;", 
        "fa-credit-card-alt": "&#xf283;", 
        "fa-trophy": "&#xf091;", 
        "fa-rouble": "&#xf158;", 
        "fa-flag": "&#xf024;", 
        "fa-rotate-left": "&#xf0e2;", 
        "fa-file-pdf-o": "&#xf1c1;"
    }

    def __init__(self, *args, **kwargs):
        super(FontawesomeField, self).__init__(*args, **kwargs)

    def to_python(self, value):
        return value

    def get_prep_value(self, value):
        return value

    def formfield(self, **kwargs):
        defaults = {'form_class': forms.ChoiceField,
                    'widget': FontawesomeSelect,
                    'choices': map(lambda (k, v): (k, v + '&nbsp;&nbsp;&nbsp;' + k), self.FontawesomeIcons.items())}
        defaults.update(kwargs)
        return super(FontawesomeField, self).formfield(**defaults)

    def get_internal_type(self):
        return 'CharField'

